import router from "@/router";

/**
 * 跳转页面
 * @param name
 * @param query
 */
export function jumpPage(name,query = {}){
  router.push({
    name: name,
    query,
  })
}

/**
 * 跳转页面 新标签打开
 * @param name
 * @param query
 */
export function jumpPageNewTag(name, query = {}){
  const { href } = router.resolve({
    name,
    query
  })
  window.open(href,'_blank')
}

function jumpView(name, query, isNewTag){
  if(isNewTag){
    jumpPageNewTag(name,query)
  }else{
    jumpPage(name,query)
  }
}

/**
 * 跳转贴标工单详情页
 * @param id
 * @param isNewTag
 */
export function jumpLabelOrderInfo(id, isNewTag = false) {
  const name = 'labelOrderInfo'
  const query = {
    id: id,
  }
  jumpView(name,query,isNewTag)
}


/**
 * 跳转货件单详情页
 * @param id
 * @param isNewTag
 */
export function jumpShipmentInfo(id, isNewTag = false){
  const name = 'shipmentInfo'
  const query = {
    id: id,
  }
  jumpView(name,query,isNewTag)
}

/**
 * 跳转到中转详情
 * @param id
 * @param isNewTag
 */
export function jumpMiddleInfo(id, isNewTag = false){
  const name = 'middleInfo'
  const query = {
    id: id,
  }
  jumpView(name,query,isNewTag)
}

/**
 * 跳转到调货工单详情
 * @param id
 * @param isNewTag
 */
export function jumpTransferInfo(id, isNewTag = false){
  const name = 'transferInfo'
  const query = {
    id: id,
  }
  jumpView(name, query, isNewTag)
}

/**
 * 跳转到组装工单详情
 * @param id
 * @param isNewTag
 */
export function jumpCombinationInfo(id, isNewTag = false) {
  const name = 'combinationInfo'
  const query = {
    id: id,
  }
  jumpView(name, query, isNewTag)
}
